﻿using System.Linq;
using InseSoft.Models.Entities;

namespace InseSoft.Models
{
    public static class ContextExtensions
    {
        public static IQueryable<CatalogEntity> OrderByName(this IQueryable<CatalogEntity> entities)
        {
            return entities.OrderBy(i => i.Nombre);
        }

        public static IQueryable<CatalogEntity> Active(this IQueryable<CatalogEntity> entities)
        {
            return entities.Where(i => i.Activo);
        }

        public static IQueryable<CatalogEntity> DropdownList(this IQueryable<CatalogEntity> entities)
        {
            return entities.Active().OrderByName();
        }
    }
}
